﻿@using Webdiyer.WebControls.Mvc;
@model PagedList<ChuangDu_Spirit_QGB_Model.CsmInfo>

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>客户服务管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="~/BootstrapSouce/css/bootstrap.css" rel="stylesheet" />
    <script src="~/BootstrapSouce/js/jquery.js"></script>
    <script src="~/BootstrapSouce/js/bootstrap.js"></script>
    <script src="~/Layui/layui-v2.2.3/layui/layui.all.js"></script>
    <script src="~/Layui/layui-v2.2.3/layui/layui.js"></script>
    <link href="~/Layui/layui-v2.2.3/layui/css/layui.mobile.css" rel="stylesheet" />
    <link href="~/Layui/layui-v2.2.3/layui/css/layui.css" rel="stylesheet" />
    <script src="~/layer/2.4/layer.js"></script>
    <script src="~/Scripts/jquery-1.10.2.js"></script>

    <script>
        //刷新
        function Refresh() {
            location.href = "CsmShow";
        }


        //这是全选反选
        function xuan(obj) {
            if (obj.checked == true) {
                $("input[name='ck']:checkbox").prop("checked", true);
            }
            else {
                $("input[name='ck']:checkbox").each(function () {
                    $(this).prop("checked", !$(this).prop("checked"));
                });
            }
        }
        //添加
        function Add() {

            var CsmName = $("#CsmName").val();
            var CsmType = $("#CsmType").val();
            var CsmServerWay = $("#CsmServerWay").val();
            var CsmSdate = $("#CsmSdate").val();
            var CsmOrder = $("#CsmOrder").val();
            var CsmStime = $("#CsmStime").val();
            var CsmPuthTime = $("#CsmPuthTime").val();
            var CsmLinkman = $("#CsmLinkman").val();
            var CsmState = $("#CsmState").val();
            var CsmExecutor = $("#CsmExecutor").val();
            var CsmTheme = $("#CsmTheme").val();
            var CsmSContent = $("#CsmSContent").val();
            var CsmFeedBack = $("#CsmFeedBack").val();
            var CsmReark = $("#CsmReark").val();
            var CsmAccessory = $("#CsmAccessory").val();

            var flag2 = false;
            var CsmName1 = /^[\u4e00-\u9fa5]+$/;
            if (!CsmName1.test(CrmNmae)) {
                $('#DneedNamemsg').text('客户名称为汉字，最大长度不超过十个字！');
                flag2 = false;
                return;
            }
            else {
                $('#DneedNamemsg').empty();
                flag2 = true;
            }

            if (flag2 == true) {
                $.ajax({
                    url: "/Pschance/CsmAdd",
                    type: "post",
                    data: {
                        CsmName: CsmName,
                        CsmType: CsmType,
                        CsmServerWay: CsmServerWay,
                        CsmSdate: CsmSdate,
                        CsmOrder: CsmOrder,
                        CsmStime: CsmStime,
                        CsmPuthTime: CsmPuthTime,
                        CsmLinkman: CsmLinkman,
                        CsmState: CsmState,
                        CsmExecutor: CsmExecutor,
                        CsmTheme: CsmTheme,
                        CsmSContent: CsmSContent,
                        CsmFeedBack: CsmFeedBack,
                        CsmReark: CsmReark,
                        CsmAccessory: CsmAccessory
                    },
                    success: function (data) {
                        if (data == 1) {
                            layer.msg("添加成功", {
                                icon: 1
                            });
                        }
                        else {
                            layer.msg("添加失败", {
                                icon: 2
                            });
                        }
                    }
                })
            }
            else
            {
                layer.msg("添加失败", {
                    icon: 2
                });
            }

        }

        //批量删除
        function Pidel() {
            var ids = [];
            $("input[name='ck']:checkbox:checked").each(function () {
                ids.push(this.value);
            })
            layer.confirm("你确定删除么？",
                { btn: ['我确定', '不想'] },
                    function (obj) {
                        $.ajax({
                            url: "/Pschance/CsmDetails",
                            type: "post",
                            data: { ids: ids.toString() },
                            success: function (data) {
                                if (data == 1) {

                                    $("input[name='ck']:checkbox:checked").each(function () {
                                        $(this).parent().parent().remove();
                                    })
                                    layer.msg("删除成功！");
                                }
                                else
                                    layer.msg("未选中，删除失败！");
                            }
                        })
                    }

                )

        }
    </script>
    <style>
        label {
            font-size: 12px;
            color: red;
            font-family: 隶书;
        }
    </style>
</head>



<body style="padding-left:30px;padding-right:30px;">
    <div style="width:100%;height:50px;margin:0 auto">
        <div class="layui-btn-group" style="float:left;padding-top:20px;">
            <button class="layui-btn layui-btn-primary" onclick="xuan(this)"><i class="layui-icon">&#xe627;</i>全选</button>
            <button class="layui-btn layui-btn-primary" onclick="Refresh()"><i class="layui-icon">&#x1002;</i>刷新</button>
            <a href="#Add" data-toggle="modal">
                <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe608;</i>新建合同/订单</button>
            </a>
            <a href="#Add" data-toggle="modal">
                <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe642;</i>编辑</button>
            </a>
            <button class="layui-btn layui-btn-primary" onclick="Pidel()"> <i class="layui-icon">&#xe640;</i>删除</button>
            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe67c;</i>导入EXCEL</button>
            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe609;</i>导出本页</button>
            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe62d;</i>导出全部</button>

        </div>
        <div class="demoTable" style="float:right;padding-right:20px;margin-top:20px;">
            <div class="layui-inline">
                <input class="layui-input" name="id" id="demoReload" autocomplete="off">
            </div>
            <button class="layui-btn"><i class="layui-icon">&#xe615;</i></button>
            <button class="layui-btn"><i class="layui-icon">&#xe614;</i></button>
        </div>
    </div>
    <div style="width:100%;height:400px;">
        <div style="width:98%;height:390px; overflow-y:scroll; overflow-x:scroll;">
            <table class="layui-table" style="text-align:center;width:120%;">

                <thead>
                    <tr style="background-color:#31b0d5;color:#ffffff">
                        <td lay-data="{type:'checkbox', fixed: 'left'}"><input id="Checkbox1" type="checkbox" /></td>
                        <td>客户名称</td>
                        <td>服务类型</td>
                        <td>服务方式</td>
                        <td>开始日期</td>
                        <td>合同/订单号</td>
                        <td>开始时间</td>
                        <td>花费时间</td>
                        <td>客户联系人 </td>
                        <td>状态 </td>
                        <td>执行人 </td>
                        <td>主题 </td>
                        <td>服务内容 </td>
                        <td>客户反馈 </td>
                        <td>备注 </td>
                        <td>附件</td>
                    </tr>
                </thead>
                @foreach (var x in Model)
                {
                    <tr>
                        <td lay-data="{type:'checkbox'}"><input id="@x.Id" type="checkbox" name="ck" value="@x.Id" /></td>
                        <td>@x.CsmName</td>
                        <td>@x.CsmType</td>
                        <td>@x.CsmServerWay</td>
                        <td>@x.CsmSdate</td>
                        <td>@x.CsmOrder</td>
                        <td>@x.CsmStime</td>
                        <td>@x.CsmPuthTime</td>
                        <td>@x.CsmLinkman</td>
                        <td>@x.CsmState</td>
                        <td>@x.CsmExecutor</td>
                        <td>@x.CsmTheme</td>
                        <td>@x.CsmSContent</td>
                        <td>@x.CsmFeedBack</td>
                        <td>@x.CsmReark</td>
                        <td>@x.CsmAccessory</td>
                    </tr>
                }

            </table>
        </div>
    </div>

    <div style="padding-left:50px;margin-top:50px;">

        <span style="font-size:16px;color:red"> @Model.CurrentPageIndex/ @Model.TotalPageCount</span> <span style="font-size:16px;color:red">
            总共 @Model.TotalItemCount 条记录
        </span>


        <div class="text-left">
            @Html.Pager(Model, new PagerOptions { PageIndexParameterName = "id", ContainerTagName = "ul", CssClass = "pagination", CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>", DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>", PagerItemTemplate = "<li>{0}</li>", Id = "bootstrappager", FirstPageText = "第一页", LastPageText = "最后一页", PrevPageText = "上一页", NextPageText = "下一页" })
        </div>
    </div>

    <fieldset class="layui-elem-field layui-field-title" style="margin-top:30px;"></fieldset>


    @*添加模态*@
    <div class="modal fade" id="Add" aria-hidden="true" style="height:500px;margin-top:50px;">
        <div class="modal-dialog">
            <div class="modal-content">
                @using (Html.BeginForm("PschanceAdd", "Pschance", FormMethod.Post))
                {
                    <div class="modal-header" style="background-color:#0094ff">
                        <h3>新增详细需求</h3>
                    </div>
                    <div class="modal-body">
                        <table class="table">
                            <tr>
                                <td>客户姓名</td>
                                <td><input type="text" id="CsmNmae" class="form-control" /></td>
                                <td colspan="2"><label id="DneedNamemsg"></label></td>
                            </tr>
                            <tr>
                                <td>服务类型</td>
                                <td><input type="text" id="CsmType" class="form-control" /></td>
                                <td colspan="2"></td>
                            </tr>
                            <tr>
                                <td>服务方式</td>
                                <td><input type="text" id="CsmServerWay" class="form-control" /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>开始日期</td>
                                <td><input type="text" id="CsmSdate" class="form-control" /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>合同/订单号</td>
                                <td colspan="2"><input type="text" id="CsmOrder" class="form-control" /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>开始时间</td>
                                <td colspan="2"><input type="date" id="CsmStime" class="form-control" /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>花费时间</td>
                                <td colspan="2"><input type="text" id="CsmPuthTime" class="form-control" /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>客户联系人</td>
                                <td colspan="2"><input type="text" id="CsmLinkman" class="form-control" /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>状态</td>
                                <td colspan="2"><input type="text" id="CsmState" class="form-control" /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>执行人</td>
                                <td colspan="2"><input type="text" id="CsmExecutor" class="form-control" /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>主题</td>
                                <td colspan="2"><input type="text" id="CsmTheme" class="form-control" /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>服务内容</td>
                                <td colspan="2"><input type="text" id="CsmSContent" class="form-control" /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>客户反馈</td>
                                <td colspan="2"><input type="text" id="CsmFeedBack" class="form-control" /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>备注</td>
                                <td colspan="2"><input type="text" id="CsmReark" class="form-control" /></td>
                                <td></td>
                            </tr>
                            <tr>
                                <td>+附件</td>
                                <td><input type="file" id="CsmAccessory" class="form-control" /></td>
                                <td></td>
                            </tr>
                        </table>


                    </div>
                    <div class="modal-footer" style="background-color:#0094ff">
                        <input type="button" data-dismiss="modal" value="返回" class="col-lg-3 col-lg-pull-0" />
                        <input type="button" value="新增" class="col-lg-3 col-lg-push-5 btn btn-success" onclick="Add()" /><br />
                    </div>

                }
            </div>


        </div>
    </div>



</body>
</html>
